package proxy;


import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;

public class ProxyServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = null;
        boolean listening = true;
        
        int defaultPort = 10000;
        try {
            defaultPort = Integer.parseInt(args[0]);
        } catch (Exception e) {}

        try {
            serverSocket = new ServerSocket(defaultPort);
            System.out.println("The ProxyServer is started on: " + defaultPort);
        } catch (IOException e) {
            System.err.println("Could not listen on port: " + args[0]);
            System.exit(-1);
        }

        while (listening) { 
        	new ProxyThread(serverSocket.accept()).start();
        }
        serverSocket.close();
    }
}